package cc.uncarbon.module.appapi.config;

import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "wechat.pay")
@Data
public class WechatPayConfig {
    private String appid;
    private String mchId;
    private String apiKey;
    private String certPath;
    private String serialNo;
    private String notifyUrl;
    private String refundUrl;

    @Bean
    public RSAAutoCertificateConfig getConfig(){
        return new RSAAutoCertificateConfig.Builder()
                .merchantId(this.getMchId())
                .privateKeyFromPath(this.getCertPath())
                .merchantSerialNumber(this.getSerialNo())
                .apiV3Key(this.getApiKey())
                .build();

    }
}
